package org.giovanolli.mumi.entities;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * The Class Bill.
 */
@Entity
@Table(name = "bill")
public class Bill extends IdentificableEntity {

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = -2981461172277462758L;

	/** The date. */
	@Column(name = "date")
	private Date date;

	/** The patient. */
	@ManyToOne
	@JoinColumn(name = "patient_id")
	private Patient patient;

	/** The bill details. */
	@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
	@JoinColumn(name = "bill_id")
	private List<BillDetail> billDetails = new ArrayList<BillDetail>();

	/** The amount. */
	@Column(name = "amount")
	private Double amount = 0d;

	/** The payment type. */
	@Enumerated(EnumType.STRING)
	@Column(name = "payment_type")
	private PaymentType paymentType;

	/** The bill id. */
	@OneToOne(cascade = CascadeType.ALL)
	private BillIdentifier billId;

	/** The patient prepaid. */
	@ManyToOne
	@JoinColumn(name = "patient_prepaid_id")
	private PatientPrepaid patientPrepaid;

	/**
	 * Gets the amount.
	 * 
	 * @return the amount
	 */
	public Double getAmount() {
		return amount;
	}

	/**
	 * Gets the bill details.
	 * 
	 * @return the bill details
	 */
	public List<BillDetail> getBillDetails() {
		return billDetails;
	}

	/**
	 * Gets the bill id.
	 * 
	 * @return the bill id
	 */
	public BillIdentifier getBillId() {
		return billId;
	}

	/**
	 * Gets the date.
	 * 
	 * @return the date
	 */
	public Date getDate() {
		return date;
	}

	/**
	 * Gets the patient.
	 * 
	 * @return the patient
	 */
	public Patient getPatient() {
		return patient;
	}

	/**
	 * Gets the patient prepaid.
	 * 
	 * @return the patient prepaid
	 */
	public PatientPrepaid getPatientPrepaid() {
		return patientPrepaid;
	}

	/**
	 * Gets the payment type.
	 * 
	 * @return the payment type
	 */
	public PaymentType getPaymentType() {
		return paymentType;
	}

	/**
	 * Sets the amount.
	 * 
	 * @param amount
	 *            the new amount
	 */
	public void setAmount(Double amount) {
		this.amount = amount;
	}

	/**
	 * Sets the bill details.
	 * 
	 * @param billDetails
	 *            the new bill details
	 */
	public void setBillDetails(List<BillDetail> billDetails) {
		this.billDetails = billDetails;
	}

	/**
	 * Sets the bill id.
	 * 
	 * @param billId
	 *            the new bill id
	 */
	public void setBillId(BillIdentifier billId) {
		this.billId = billId;
	}

	/**
	 * Sets the date.
	 * 
	 * @param date
	 *            the new date
	 */
	public void setDate(Date date) {
		this.date = date;
	}

	/**
	 * Sets the patient.
	 * 
	 * @param patient
	 *            the new patient
	 */
	public void setPatient(Patient patient) {
		this.patient = patient;
	}

	/**
	 * Sets the patient prepaid.
	 * 
	 * @param patientPrepaid
	 *            the new patient prepaid
	 */
	public void setPatientPrepaid(PatientPrepaid patientPrepaid) {
		this.patientPrepaid = patientPrepaid;
	}

	/**
	 * Sets the payment type.
	 * 
	 * @param paymentType
	 *            the new payment type
	 */
	public void setPaymentType(PaymentType paymentType) {
		this.paymentType = paymentType;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.giovanolli.mumi.entities.IdentificableEntity#toString()
	 */
	@Override
	public String toString() {
		return "Bill [date=" + date + ", patient=" + patient + "]";
	}
}
